package cn.arikeky.basic.controller;

import cn.arikeky.basic.dto.EmailDto;
import cn.arikeky.basic.service.IVerifyCodeService;
import cn.arikeky.basic.util.AjaxResult;
import cn.arikeky.basic.dto.RegisterDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/verifyCode")
public class VerifyCodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService;
    /**
     * 获取图形验证码
     */
    @GetMapping("/image/{key}")
    public AjaxResult graph(@PathVariable("key") String key){
        String base64Str = verifyCodeService.graph(key);
        return AjaxResult.me().success(base64Str);

    }
    /**
     * 获取短信验证码
     */
    @PostMapping("/smsCode")
    public AjaxResult smsCode(@RequestBody RegisterDto vo){
        verifyCodeService.smsCode(vo);
        return AjaxResult.me().success("系统繁忙！请稍后重试！");
    }
    /**
     * 获取邮箱验证码
     */
    @PostMapping("/emailCode")
    public AjaxResult emailCode(@RequestBody EmailDto dto){
        System.out.println(dto);
        verifyCodeService.emailCode(dto);
        return AjaxResult.me().success("系统繁忙！请稍后重试！");
    }


}
